﻿// ===============================================================================
// ZipcodeRuleTest.cs
// EOS Framework
// ===============================================================================
// Copyright (c) EOS Development Group. All rights reserved.
// ===============================================================================

namespace EOS.Framework.Rules.Tests
{
    using EOS.Framework.Rules;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// This is a test class for ZipcodeRuleTest and is intended
    /// to contain all ZipcodeRuleTest Unit Tests
    /// </summary>
    [TestClass()]
    public class ZipcodeRuleTest
    {
        private TestContext testContextInstance;

        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }        
        
        /// <summary>
        /// A test for Validate.
        ///</summary>
        [TestMethod()]
        public void ZipcodeRuleValidateTest()
        {
            Rule rule = new ZipcodeRule("Test");
            bool result = false;

            result = rule.Validate(12345);
            Assert.IsTrue(result, "Zipcode not accepted.");

            result = rule.Validate(123);
            Assert.IsFalse(result, "Too short zipcode accepted.");

            result = rule.Validate(123456);
            Assert.IsFalse(result, "Too long zipcode was accepted.");

            result = rule.Validate("Hello");
            Assert.IsFalse(result, "Simple word was accepted.");
        }

        /// <summary>
        /// A test for Validate.
        ///</summary>
        [TestMethod()]
        public void ZipcodeRuleValidateEmptyTest()
        {
            Rule rule = new ZipcodeRule("Test", true);
            bool result = false;

            result = rule.Validate(string.Empty);
            Assert.IsTrue(result, "Empty string accepted.");
        }
    }
}
